package com.aaa.springbootredis.controller;

import com.aaa.springbootredis.entity.User;
import com.aaa.springbootredis.service.Userservice;
import jdk.nashorn.internal.runtime.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @author:LiWei
 * @date:2022年12月07日10:12
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private Userservice userservice;

    @GetMapping("/getById/{id}")
    public User getById(@PathVariable Integer id){
        return userservice.findById(id);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return userservice.delete(id);
    }

    @PostMapping
    public User save(@RequestBody User dept){

        return userservice.save(dept);
    }

    @PutMapping
    public User update(@RequestBody User dept){
        return userservice.update(dept);
    }
}
